﻿Public Class Form1


    Private m_Request As WrapNetflix.RequestToken
    Private m_Token As WrapNetflix.AccessToken
    Dim con As New WrapNetflix.NetflixConnection("makkq6wsbkh6cd4nt9nzjf7y", "z2p4Dwnxap")
    Dim searchList As New Queue(Of String)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = "Button 1"
        Try
            TextBox1.Text = String.Join(vbCrLf, con.Catalog.TitlesForAutocomplete(searchList.Dequeue).ToArray)
        Catch ex As Exception
            TextBox1.Text = ex.ToString
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = "Button 2"
        Try
            If m_Request Is Nothing Then
                m_Request = con.GenerateRequestToken
                Dim newVariable As String = "Iexplore.exe " & m_Request.PermissionUrl
                Shell(newVariable)

            Else

                m_Token = m_Request.ConvertToAccessToken
                Dim user As New WrapNetflix.User(m_Token, con)
                TextBox1.Text &= user.InstantQueue.Count
            End If
        Catch ex As Exception
            TextBox1.Text = ex.ToString
        End Try
    End Sub

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Enqueue any initialization after the InitializeComponent() call.
        searchList.Enqueue("T")
        searchList.Enqueue("To")
        searchList.Enqueue("Tom")
        searchList.Enqueue("Tom ")
        searchList.Enqueue("Tom J")
        searchList.Enqueue("Tom Jo")
        searchList.Enqueue("Tom Jon")
        searchList.Enqueue("Tom Jone")
        searchList.Enqueue("Tom Jones")

    End Sub
End Class
